//
//  ShopCarTableViewCell.m
//  Mahjong
//
//  Created by KING on 16/9/9.
//  Copyright © 2016年 swift. All rights reserved.
//

#import "ShopCarTableViewCell.h"

@implementation ShopCarTableViewCell
- (IBAction)seleAction:(UIButton *)sender {
    sender.selected  = !sender.selected;
    
}
- (IBAction)deleAction:(id)sender {
    self.number = self.number-1;
    self.conLabel.text = [NSString stringWithFormat:@"%ld",self.number];
}
- (IBAction)addAction:(id)sender {
    self.number = self.number+1;
    self.conLabel.text = [NSString stringWithFormat:@"%ld",self.number];
    

}
-(void)drawRect:(CGRect)rect{
    [super drawRect:rect];
    self.number = 1;
    self.deleButton.backgroundColor = [UIColor colorWithRed:239/255.0 green:239/255.0 blue:239/255.0 alpha:1];
     self.addButton.backgroundColor = [UIColor colorWithRed:239/255.0 green:239/255.0 blue:239/255.0 alpha:1];
   
    [self.seleButton setImage:[UIImage imageNamed:@"选择"] forState:UIControlStateNormal];
    [self.seleButton setImage:[UIImage imageNamed:@"选择1"] forState:UIControlStateSelected];
//    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"carSele"] isEqualToString:@"1"]) {
//        [self.seleButton setImage:[UIImage imageNamed:@"选择1"] forState:UIControlStateNormal];
//        [self.seleButton setImage:[UIImage imageNamed:@"选择"] forState:UIControlStateSelected];
//    }
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(carSele:) name:@"carSele" object:nil];

}
-(void)carSele:(NSNotification *)not{
    if ([not.object isEqualToString:@"1"]) {
        self.seleButton.selected = YES;


    }
    if ([not.object isEqualToString:@"0"]) {
        self.seleButton.selected = NO;


    }
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
